package main

import (
	"bg/libs"
	"fmt"
)
import "net/http"
import "bg/route"

// import "strings"
func main() {

	fmt.Println("web server is start")
	route.Register() //注册路由

	//测试
	// http.Handle("/hello", http.NotFoundHandler())

	//文件处理器
	//图片
	file := libs.GetSourcePath()
	http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir(file+"/img"))))
	//页面
	http.Handle("/html/", http.StripPrefix("/html/", http.FileServer(http.Dir(file+"/html"))))
	//js,css
	http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(file+"/static"))))

	err1 := http.ListenAndServe("127.0.0.1:8888", nil)
	if err1 != nil {
		fmt.Println(err1)
	}
}
